#GovRpWC.py
import jieba
import wordcloud
from scipy.misc import imread

def v1WordClound(txtname):
    f = open(txtname,"r",encoding="utf-8")
    t = f.read()
    f.close()
    ls = jieba.lcut(t)
    txt = " ".join(ls)
    w = wordcloud.WordCloud( font_path="msyh.ttc",\
                            width = 1000,height = 700,\
                            background_color = "white")
    w.generate(txt)
    w.to_file("govwordcloud.png")

def v2WordClound(txtname):
    mask = imread("fivestar.png")
    f = open(txtname,"r",encoding="utf-8")
    t = f.read()
    f.close()
    ls = jieba.lcut(t)
    txt = " ".join(ls)
    w = wordcloud.WordCloud( font_path="msyh.ttc",mask=mask,\
                            width=1000,height=700,\
                            background_color = "white")
    w.generate(txt)
    w.to_file("govwordcloud.png")
